<%@page import="com.beans.CategoryForm"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="com.DAO.*,java.util.*;"%>
    <%!int i=0;String str=null; %>
  <%@taglib prefix="getData" uri="/WEB-INF/CustomTagDescriptor.tld" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel = "stylesheet" href = "style/Global.css" />

<script language="javaScript" type="text/javascript" src="scripts/calendar.js"></script>
 </head>
<%
 String op=request.getParameter("op");
if(op!=null)
{
    
    if(op.equals("next")){
    	   
    	   String counter=request.getParameter("counter");
    	   if(counter==null){
    		   i=0;    		   
    	   }
    	   else{
    		   
    		    i=Integer.parseInt(counter)+1;
    	   }
       }   
    } 
    else
    {
    	String counter=request.getParameter("counter");
    	if(counter==null){
 		   i=0;    		   
 	   }
 	   else if(Integer.parseInt(counter)>0){
 		     i=Integer.parseInt(counter)-1;
 	   }
    	
    }

%>



<body onload = "loadDefaultExpiryDate()">
	<fieldset id = "postform">
		<legend>
			Notice
		</legend>
		<form method="post" action="NoticeForm.do">
			
				<div class = "titletext">Title</div>
				<input class = "inputelement" type = "text" name="title">
				<br>
				<div class = "titletext">Category</div>
				
				<select class = "inputelement" name="categoryName">
					<%!					
						CategoryDAO categorydao = new CategoryDAO();
						ArrayList<CategoryForm> cl;
					%>
					<%					
					String user=(String)session.getAttribute("user_type");
					try {
				/**
				   make changes
				*/
					cl = categorydao.get();
					for(int i = 0; i < cl.size(); i++){
						            
									if(!cl.get(i).getName().equals("Announcements") 
											&& !cl.get(i).getName().equals("Birthday")
											&& !cl.get(i).getName().equals("Client Appreciation")) {
										%><option><%=cl.get(i).getName() %></option><%
									} else if(user.equals("admin")) {
										%><option><%=cl.get(i).getName() %></option><%
									}								
						}
					} catch(Exception e) {
						
					}
					%>
			</select><br>
			<div class = "titletext">Expiry Date</div>
			<input id = datum" class = "inputelement" type = "text" name = "expirationDate">
			<a href="#" onClick="setYears(2012, 2020);showCalender(this, 'expirationDate');">
     		<img src="image/calender.png"></a>
			
			 <!-- Calender Script  --> 

    <table id="calenderTable">
        <tbody id="calenderTableHead">
          <tr>
            <td colspan="4" align="center">
	          <select onChange="showCalenderBody(createCalender(document.getElementById('selectYear').value,
	           this.selectedIndex, false));" id="selectMonth">
	              <option value="0">Jan</option>
	              <option value="1">Feb</option>
	              <option value="2">Mar</option>
	              <option value="3">Apr</option>
	              <option value="4">May</option>
	              <option value="5">Jun</option>
	              <option value="6">Jul</option>
	              <option value="7">Aug</option>
	              <option value="8">Sep</option>
	              <option value="9">Oct</option>
	              <option value="10">Nov</option>
	              <option value="11">Dec</option>
	          </select>
            </td>
            <td colspan="2" align="center">
			    <select onChange="showCalenderBody(createCalender(this.value, 
				document.getElementById('selectMonth').selectedIndex, false));" id="selectYear">
				</select>
			</td>
            <td align="center">
			    <a href="#" onClick="closeCalender();"><font color="#003333" size="+1">X</font></a>
			</td>
		  </tr>
       </tbody>
       <tbody id="calenderTableDays">
         <tr style="">
           <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
         </tr>
       </tbody>
       <tbody id="calender"></tbody>
    </table>

<!-- End Calender Script  --> 
			<br>
			
			
			<br>
			<div class = "titletext">Discription</div>
			<textarea class = "inputelement" rows="3" name="description"></textarea>
			<div id = "btndiv"><input  id = "btnsubmit" type = "submit" name = "submit" value = "Post"></div>
		</form>
	</fieldset>
	<%str=i+""; %>
	
	<getData:notice1 cursor="<%=str%>" category="0"/>
	
	<div id = "pager">	 
	<a id = "btnprev" href="noticeform-1.jsp?counter=<%=str%>&op=pre"> Previous</a>
	<a id = "btnnext" href="noticeform-1.jsp?counter=<%=str%>&op=next">Next </a>	 
	</div>
	
</body>


</html>